/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package technotheist.geo.graph;

import com.jme3.math.Plane;
import com.jme3.math.Vector3f;

/**
 *
 * @author Mitch
 */
public abstract class GeoNode<Node extends GeoNode, Dual extends GeoNode> {

    Vector3f pos;
    final GeoGrid grid;

    protected GeoNode(Vector3f pos, final GeoGrid grid) {
        this.grid = grid;
        this.pos = pos;
    }

    public GeoNode(float x, float y, float z, final GeoGrid grid) {
        this.grid = grid;
        this.pos = new Vector3f(x, y, z);
    }

    public abstract int ID();

    public abstract int sideCount();

    public abstract HalfEdge<Dual, Node> getBoundEdge(int i);

    public abstract HalfEdge<Node, Dual> getNextEdge(int i);

    public boolean containsPoint(Vector3f pt) {
        for (int i = 0; i < sideCount(); i++) {
            if (getBoundEdge(i).side(pt) == Plane.Side.Negative) {
                return false;
            }
        }
        return true;
    }
}
